Lots of incremental changes
Fixes to tests