Added sanity checks in unit tests + documentation.