Use mock.patch the right way in tests.