Improve validations and add tests for them