added testcase and fixed implementation