more tests and test support, fix bugs