fix handling of connection errors and add coverage