Fix a couple of bugs, and resuscitate some old tests.