Fix crash from missing $ctx object.
Introduced with some of the code refactoring in this branch only. Test added to verify we can at least get through generating the module list.