made some code and test refactoring per homework comments from Jason