EventDispatcher: fix a few tricky cases regarding Timers
- Do not compare pointers to a Timer that may have been deleted. A different Timer may have been allocated at the same memory address. This failed at least when the new timer (or, in fact, the current timer) had the timeout changed since removing it. There may have been different failure cases, too.
- Make timeToNextDueTimer() always safe to call from the listener of the currently triggered timer, even after the has been removed from its triggered handler. The way it is done is safe against the problem described above.
- Do not look at the currently triggered timer in addTimer(); it might have been deleted already.
With a new test that was very helpful in finding and fixing the
issues.