bug fix and add test files