Fix global leak and added global leak detection in tests

Similar fix to #8 with some extras.

Upgraded to latest version of tape.