More tests and minor bug fix.