Started refactoring project. Added tests.