cleanup, fixes and more tests