Fix memory leak in OSX test code