fixed the tests, fixed some bugs