add validation and fix tests