Refactor utilities for validating positional arguments

Fixes #862