issue #4: implement unit and integration test cases (and required refactorings)