Fix Axis.Category position bug caused by mistake in table layout

Fix works by setting the width and height of component sooner, and
ensuring that it is never greater than offered width.

Code is also cleaner.
Add a unit test.
Close #1188.