Unit tests and updates to modules.

Partial implementation of unit tests, various updates to modules.