Refactor test environment validations

Review: https://reviews.apache.org/r/25569