Commented the code to descibe the test cases and make the code more easily understandable