more test revealed several bugs, but they are now fixed, all tests passing