More tests and some minor fixes