Moved get_modules to its own function and added tests