bug fix and add test suites