Update event tests

Add a test for replacing events. Update the tests for adding and canceling tests, use new macro WAITFOR to make tests more reliable and speed up test runs by minimizing unnecessary waiting.