Merge pull request #112 from tribal-tec/master

Fix racy connection handshake
Issue40
Compile and tests working
CR #40