added null check for rows. updated test case