Instead of sleeping wait for ports to be open

After starting selenium and phantomjs run a loop and wait for the ports to be active for those services.
Merge pull request #602 from jrjohnson/waitforports

Instead of sleeping wait for ports to be open