fix all of the bugs and tests