ENG-7187 fixed bug and added testcase