#9 + refactoring, method implementation and unit tests