Split test_functional.py into multiple files, fix some existing tests