Add mock.py and replace some of the more egregious mocking logic in a couple tests.