Refactor validity, but tests still have problems