Add some debugging helpers and two tests that currently fail.

Also includes one leak fix.  Need moar valgrind.