Adding logic to check module dependencies at module loading time

Provides implementation for #3427