Split index into ModuleSystem and ModuleLoader, + tests