Fixed validate functions, updated tests