Optimize test packages recording logic