Fix port selection
Add testcase for connection
Run tests on build