(PDB-581) Add subqueries to events query endpoint
(PDB-581) Add tests and minor cleanups for event subqueries

This patch augments Dalen's patch by adding tests. For symmetry I've rolled up
the v3 & v4 version of the events test into one.

I've also moved some of the functions in query/events.clj into query.clj to
match the other related code for facts, resources and nodes.

Signed-off-by: Ken Barber <ken@bob.sh>
Merge pull request #922 from kbarber/ticket/master/pdb-581-event-subqueries

Ticket/master/pdb 581 event subqueries