Implemented test cases with a few fixes