Refactored to use class methods and class spies