libtap: flush buffers after plans and results

This seems better than re-enabling setbuf(stdout, 0), and seems
necessary to avoid confusing outputs in corner cases, especially
if the test code dies between tests or before the first result.
some further refactoring for the libgdmaps test stuff