MDL-37028 Integrity check for course modules and sections

created function, unittest, and build-in the quick integrity check on each call to rebuild_course_cache()
New function assertDebuggingCalledMultiple()