more tests, bug fixes