Change to tests logic to improve code reuse