optimize test code