Add validation and fix functional tests