fixed some bugs, tests, etc.