Created tests and refactored some code along the way