add validations and some unit tests