refactor functional tests