bug fixes and tests
it works!