Fix broken tests and a bug with the event queries