Refactor into a harmless connection func to ease testing of error conditions.
Add test for harmless error function.