fix tests broken in 46893f6

It turns out that the change to log stuff into output/log.txt changed
the order of the header and the message of loading shared libs, which
broke 40 tests. This fix restores the original order and only prints the
header into the logfile as soon as that one is set up.