Move log collection to before test run.

Fix quoting problems