Refactoring, adding more unit tests;