added validation functions + tests