Migrated code that checks for common programmer errors to a separated function and added test coverage for it. Wrong comment stating that a typed error is returned was also removed. Kubernetes-commit: ad5fafd6ade2838098890a4e7727c8e347686867