Issue #28 - unit test modules and fix bugs