Adds test and fix for overflow in capacity calculation in resizing sparse matrices.

For large integer overflow, checking if result is below zero is not enough.
Even for fairly small matrices (~ 65000 x 65000) this is a problem.