corrected some bugs and some tests. We're left with 1 test failure for now.