Move event serialization to separate method and add tests

Testing validation of EL upon faulty serialization.
These tests have uncovered a bug:
https://bugzilla.wikimedia.org/show_bug.cgi?id=65607

The bug will be fixed in a subsequent commit

Author: Nuria Ruiz <nuria@wikimedia.org>
Change-Id: If7c155860d6acb596ffc1529f1653dc5aea0b91f