tests: Fix various small memory leaks
See the commit messages. This fixes various small memory leaks from this CI run. It doesn’t fix all the memory leaks; I left the harder ones for when I (or someone else) has more time.
All of these fixes are in unit test code, rather than actual GLib code.
Signed-off-by: Philip Withnall pwithnall@endlessos.org