Network failure resilience

Reworks connection handling to improve resilience in the face of network failures. Adds a suite of tests to simulate network failures using a simple TCP proxy.