Add a test for the cyclic reference leak issue, and fix tests so that they run on Python 3.2