fixed some bugs, tests still fail