Added unit tests and refactored code to facilitate unit testing. Ensured
100% test coverage.