More tests and a bug fix.