middleware and validation delegates and tests