Refactoring mock stuff to make it more extensible.