Checking validation code - rewriting with more modular code and tests