unit tests and bug fixes for things revealed by them
couple of test files