Fix coverity issues #72942, #72041 and #72040
Fix behavior of test