fixed many bugs and added tests for validator

Signed-off-by: unknown <boris@boris-PC2.gspaces.com>