tests: Fix memory leaks
Merge pull request #1836 from libgit2/ntk/fix/leaks

Fix memory leaks