Improve test case code