Fix memory leaks in shared random unit tests: simple version

Please merge https://github.com/torproject/tor/pull/774 to the mainline branches. I'll merge to to 0.2.9 and later after the mainline CI passes.