Sem: bug fix and added testcase