refactor into server and client libs, one test binary, threads