How about having only one static `git_reference` declaration and performing the `lookup()` in each of the tests rather than in the `initialize()` function?  This way, the `cleanup()` would only call `git_reference_free()` once.