CFY-1604 improve input validations and tests.