fix module reinitialization bug

- fix modules getting reinitialized when going out of scope
- compare modules by its symbol
- add module reinitialization test