refactor, use mockito, update tests