Refactored to use OOP and unittest, specced out in comments and user story