SetPiece - refactoring the test to remove code duplication

Most of the `connection_impl` tests need to set up a connection before testing logic can be run. The code to set up the connection was repeated in each test that needed it and in many cases it was the bigger part of the test. To fix this I created a helper method that creates and sets up a test connection and updated the tests to use it where it was possible.