Validate

Update validate logic, add few junit tests