more tests and bug fix