Added integration tests for premature closing of modules