functional-tests: Fix many remaining issues
Due to a mistake in the test runner, it was possible for tests to fail but appear to have succeeded.
There were many remaining issues in the functional-tests which were hidden due to the test-runner problem. This branch fixes all the issues that I've spotted, and the CI is now passing for real :-)