code refactor for tests