Move logic to testable class