Finish initial test suite and fix bugs