anchor.diff:      State.
   
   %%--------------------------------------------------------------------
  -%% Function: start_next_client_transaction(State)
  +%% Function: start_next_client_transaction(Status, State)
  +%%           Status = integer(), SIP status code of last branch result
  +%%           State  = state record()
   %% Descrip.: When this function is called, any previous client
   %%           transactions will have received a final response. Start
   %%           the next client transaction from State#state.dstlist, or
   %%           send a 500 response in case we have no destinations left.
   %% Returns : NewState = state record()
   %%--------------------------------------------------------------------
  -start_next_client_transaction(#state{cancelled = false} = State) ->
  -    case get_next_client_transaction_params(State) of
  +start_next_client_transaction(Status, #state{cancelled = false} = State) ->
  +    case get_next_client_transaction_params(Status, State) of
   	{ok, NewRequest, FirstDst, BranchTimeout, NewState} ->
  -	    case local:start_client_transaction(NewRequest, FirstDst, NewState#state.branch, BranchTimeout) of
  -		BranchPid when is_pid(BranchPid) ->
  -		    NewState#state{clienttransaction_pid = BranchPid};
  -		{error, E} ->
  -		    logger:log(error, "sippipe: Failed starting client transaction : ~p", [E]),
  -		    erlang:exit(failed_starting_client_transaction)
  +	    case State#state.testing of
  +		true ->
  +		    self() ! {start_client_transaction, NewRequest, FirstDst, BranchTimeout, NewState},
  +		    NewState;
  +		false ->
  +		    case local:start_client_transaction(NewRequest, FirstDst, NewState#state.branch, BranchTimeout) of
  +			BranchPid when is_pid(BranchPid) ->
  +			    NewState#state{clienttransaction_pid = BranchPid};
  +			{error, E} ->
  +			    logger:log(error, "sippipe: Failed starting client transaction : ~p", [E]),
  +			    erlang:exit(failed_starting_client_transaction)
  +		    end
   	    end;
  -	{siperror, Status, Reason, ExtraHeaders} ->
  -	    transactionlayer:send_response_handler(State#state.serverhandler, Status, Reason, ExtraHeaders),
  +	{siperror, Status1, Reason1, ExtraHeaders} ->
  +	    transactionlayer:send_response_handler(State#state.serverhandler, Status1, Reason1, ExtraHeaders),
   	    State#state{clienttransaction_pid	= none,
   			branch			= none,
   			dstlist			= []
   		       }
       end.
   
  -%% part of start_next_client_transaction/1
  +%% part of start_next_client_transaction/2
   %% Returns : {ok, NewRequest, FirstDst, BranchTimeout, NewState} |
   %%           {siperror, Status, Reason, ExtraHeaders}
  -get_next_client_transaction_params(State) when is_record(State, state) ->
  +get_next_client_transaction_params(Status, State) when is_record(State, state) ->
       case State#state.dstlist of
   	[_LastDst] ->
  -	    logger:log(debug, "sippipe: There are no more destinations to try for this target - " ++
  +	    logger:log(debug, "sippipe: There are no more destinations to try for this target - "
   		       "telling server transaction to answer 500 No reachable destination"),
   	    %% RFC3261 #16.7 bullet 6 says we SHOULD generate a 500 if a 503 is the best we've got
   	    {siperror, 500, "No reachable destination", []};
   	[_FailedDst | DstList] ->
  -	    case get_next_sipdst(DstList, State#state.approxmsgsize) of
  +	    case get_next_client_transaction_sipdst(DstList, State#state.approxmsgsize, Status) of
   		[FirstDst | _] = NewDstList when is_record(FirstDst, sipdst) ->
   		    NewBranch = get_next_target_branch(State#state.branch),
   		    Request = State#state.request,
  
positive.code:     transactionlayer:send_proxy_response_handler(State#state.serverhandler, Response),
      State.
  
  default_process_received_response(503, _Reason, _Response, State) when is_record(State, state) ->
      start_next_client_transaction(State);
  default_process_received_response(Status, Reason, Response, State) when is_record(State, state) ->
      logger:log(debug, "sippipe: Piping final response '~p ~s' to server transaction ~p",
  	       [Status, Reason, State#state.serverhandler]),
  
negative.code: test() ->
      yxa_test_config:init(incomingproxy, [{sipsocket_blacklisting, false}]),
  
  
      %% get_next_target_branch(In)
      %%--------------------------------------------------------------------
      autotest:mark(?LINE, "get_next_target_branch/1 - 1"),
  