First version of unit tested refactoring.