Running a more or less simple test a few times often don’t reveal subtle race conditions. Unfortunately
See also RTOS for ARM Cortex-M and e.g. this post Understanding priority levels of ISR and FreeRTOS APIs - #16 by aggarg (there are more here in the forum) for some more maybe interesting details.
The reason for the asserts is helping to ensure proper use of the API as documented.
That’s the purpose of those contracts. Nothing special.