Implement some tests for AgentAPI

Maybe the tests for creating creating a new agent and for querying it ought to be two separate tests, but I couldn't find out how to make them run in the right order.