Added basic unit tests (consistency/safety; need correctness).