Try to make the tests compatible again with 1.8.7 and above

* Use File.open() { f.write } instead of File.write
* Use require(File.expand_path(...)) instead of require_relative
Make tests wait until they can reach the server port

This should eliminate the race conditions where the control socket
exists but the server port isn't open yet.