Tests: Fix some tests under CFLAGS=-DNDEBUG CXXFLAGS=-DNDEBUG

Fixes: #23888
7 files changed