Add some more tests and minor fixes