small refactoring and adjusted tests accordingly