Refactor Functional tests