Fix validations and add tests for it