Refactor for testing.  Add mockito.