Refactor validation logic into separate function so we can
use it as an assertion.
Add validation tests and fix noargs case.
Merge branch 'feature/exposevalidation' into develop