Created the ideal test case and fixed all the bugs in the code