tests: more portability fixes.
tests: implement file helpers, just used for tests.