Refactor, and added unit test project.