Created functional_test struct and associated functions.

Extracted most code from run_tests() into various functional_test functions.