remove duplicate code in test classes