complete refactoring for ajax validation and some tests