Refactor TestReferenceData lifetime management
Keep a global instance of the TestReferenceData implementation object,
and add a test event listener that interacts with it. This allows
moving the final processing for the reference data out of the
destructor, making it behave better with exceptions, and still keeping
the same simple interface that the class provides. This enables further
refactoring that would otherwise add a lot more logic into the
destructor. Also, better sanity checks are possible for incorrect usage
of the reference data (e.g., creating multiple instances within the same
test).
Move libxml2 cleanup into the same listener to have it done at a more
appropriate step.
Change-Id: I69f85aca68a0e0374093ea169bd4ef6c0431caff