recipe refactoring and added unit testing