more refactoring/unittests