Refactor dynamic validation, test for it