refactor for unit tests