Fixing leaks.

Memory leaks on module and test fixed.