Changes for the Null pointer issue and added few more test cases