Changed working directory, small refactoring, added test coverage