tests and a bug fix