Add test to detect memory leaks in the future.

I confirmed that it does indeed fail if I comment out either of the calls
to `weaken()` in the module.