Various fixes/cleanups for tests and autofoo