unit test + bug fix