added module tests and fixed uncovered bugs.