Looks like the problem is solved
Added testcases