Adding check for null and test case.