Added new tests
Refactor to common validation code