Replace monkey patching with mock.patch