Finished the remaining tests, refactored a little (badly)