Fix for a NullPointerException when starting up with pending events in the database.  This has been fixed in master already.  I have also included a unit test that would have caught it.
Merged #288