Avoid leaking mocks across unit tests

In several unit tests, add setUp and tearDown logic to make sure that
mocked functions are restored to their default implementation. Otherwise
a leaked mock can cause another test to fail intermittently.

Change-Id: I849a88cab45398592379c54210df2e3a97197c8c
Closes-Bug: 1363192