Handle null agentId
Change expected state before executing state change method