Refactor ConnectionReceiver and begin to add tests