refactor validations and some tests