Check that width/height are non-zero

Also add some tests
Whitespace fixes