tests: ztest: Fix issues due to test case of accessing NULL address Fix issue #31339 and #31419, test case fail due to access NULL did not trigger a fatal error in some platform such as nsim_em and iotdk. Signed-off-by: Enjia Mai <enjiax.mai@intel.com>