Reviewer Graeme - Fix up some memory leaks

These are the fixes to the memory leaks you were seeing in UT.

Please don't merge, as I want to include https://github.com/Metaswitch/cpp-common/pull/93 in this merge.