Some refactoring to the test caseswq