Refactor for tests