refactored util to validator, wrote some tests