Fix potential nil ptr seg fault and CI test issue