Add a test, fix a bug, address some of Jco's comments