Replace stdio f* functions with posix open/close/read/write functions. Tests pass now.