Check if the shape is not null before querying its ShapeType. Create test case for the bug. Small correction of test case for issue CR27862