What if $\operatorname{div}f=0$? Say, we have a function $f\in C^1(\mathbb R^2, \mathbb R^2)$ such that $\operatorname{div}f=0$. According to the divergence theorem the flux through the boundary surface of any solid region equals zero. 
So for $f(x,y)=(y^2,x^2)$ the flux through the boundary surface on the picture (sorry for its thickness, please treat it as a line) is zero. 

The result (if I interpret the theorem correctly) seems to be quite surprising.
It looks like can also get non-zero flux by zero divergence. For example, $$g(x,y)=(-\frac{x}{x^2+y^2},-\frac{y}{x^2+y^2})$$ (see the next picture) has $\operatorname{div}g=0$ yet the flux is clearly negative.

The function $g$ isn't continuous at $(0,0)$ and therefore not $C^1$.
My first question is: are there any other cases where divergence is zero yet the flux isn't?
The reasons I'm asking is the exercise I came across:

Compute the surface integral
  $$\int_{U}F  \cdot dS$$
  where $F(x,y)=(y^3, z^3, x^3)$ and $U$ is the unit sphere.

I didn't expect the exercise to be doable mentally (by simply noting that $\operatorname{div}F=0$ and concluding the integral is zero) yet $F$ is clearly $C^1$ so the divergence theorem seems to be applicable. My second question is: am I overlooking something in the exercise?

The divergence theorem is a statement about 3-dimensional vector fields, the 2-dimensional version sometimes being called the normal version of Green's theorem. In your second example, the vector field 
$$g(x,y) = \left( -\frac{x}{x^2+y^2}, -\frac{y}{x^2+y^2} \right)$$
is not even defined at the origin, which is why Green's theorem doesn't apply to it. In the final problem though, the vector field $F$ is well-defined (and $C^1$) everywhere on $\mathbb{R}^3$, so you can apply the divergence theorem, and conclude that the flux is $0$. 
