Solution refactoring and added unit tests