Fix crash during unit test exit (closes #67).

Need to revisit all PyObject* handling functions at some point and
documenting them as returning a "borrowed" or "new" reference, and
ensuring those semantics carry across to the variously undocumented and
inconsistent Python APIs.