Fix default required keys

If you don't explicitely pass default_required_keys in the closure, you can
get weird behavior where this variable will stay the same across multiple
runs.

Also adding unittest-style tests to ease debugging with pdb. Doctests make it
very difficult to use pdb. Not that the bug that this commit is fixing is very
difficult to reproduce.