refactoring and purchase tests