Snippet refactoring and unit testing.