Fix races in events.from and add a test case (master edition)

CloudStack uses 1 session and multiple threads, each calling event.from. Unfortunately each thread shared state on the server, causing some of these threads to spuriously fail with SESSION_INVALID (triggering task cleanup and cascading errors).
CloudStack expects an empty event set to signify an error. Unfortunately a badly-timed Modify followed by a Delete could cause this to happen
The new test case captures the first failure triggered by CloudStack. It fails without the fix and passes afterwards.

This code has had some careful review from @jonludlam