Validation code, currently only used in the tests