Refactor to better support TestAgents