test fixes, fixes for bugs in code found by the tests