Refactor to test