More tests and minor fixes