Fixed some bugs that were breaking unit tests.