Pre refactor to remove duplication in functional_tests.py
Finished refactor of functional_tests.py