fixed a typo, simplifications
moved validator to test environment, added test