refactor AgentTest.cpp