More refactoring and tests
Fix bug in validating required params in Validator