Handle null arrays when retrieving array size

1. Check if an array is null before getting the array size
2. Add for loop testcases with null as the array to iterate