Circular dependency test for #5651

Additional tests for circular dependencies and making sure loading a module from another module does not end up in an infinite loop.