Use getattr instead of static routing dictionary
Move response handling to dedicated function
Add valid module name test case
Remove test of registered modules
Close file on stream end