Fix for ENG-5816 NPE with test case.
(cherry picked from commit c12c6fbcedc2dc99e0739fd9d7e7413d309841d8)