More tests and fix a bug