Tests: Mitigate race condition in test_clientagent with set_state