Small refactoring and added test