anchor.diff:  	    Module:send(Socket, ?FOUR_BAD_REQUEST) 
       end.
   
  -validate_cookie_path_msg(Response, IsSubPath, Cookie) ->
  +validate_cookie(Response, Fun, Params) ->
       fun(Module, Socket, _Request, Headers, _Body) ->
               case proplists:get_value("Test", Headers) of
                   "first" ->
                       Module:send(Socket, Response);
                   "second" ->
  -                    case check_cookie_path(Headers, IsSubPath, Cookie) of
  +                    case erlang:apply(Fun, [Headers | Params]) of
                           true ->
                               Module:send(Socket, ?TWO_OK);
                           false ->
                               Module:send(Socket, ?FOUR_BAD_REQUEST)
                       end
               end
  -    end.
  -
  -validate_cookie_max_age(Response, Expires, Cookie) ->
  -    fun(Module, Socket, _Request, Headers, _Body) ->
  -            case proplists:get_value("Test", Headers) of
  -                "first" ->
  -                    Module:send(Socket, Response);
  -                "second" ->
  -                    case check_cookie_max_age(Headers, Expires, Cookie) of
  -                        true ->
  -                            Module:send(Socket, ?TWO_OK);
  -                        false ->
  -                            Module:send(Socket, ?FOUR_BAD_REQUEST)
  -                    end
  -            end
  -    end.
  +    end.    
   
   validate_cookie_supersede(FirstResponse, SecondResponse, Supersede, FirstPair,
                             SecondPair) ->
  
positive.code:          {valid_http_request(), cookie_max_age(), valid_http_response()},
           begin
               ResponseBin = build_response(Response, [Cookie]),
               ValidationFun = validate_cookie_max_age(ResponseBin, Expires, Cookie),
               WaitTime = case Expires of
                              true ->
                                  MaxAge*1000;
                              false ->
                                  0
                          end,
               [FirstResponse, SecondResponse] =
                   send_cookie_requests(Host, Ssl, Family, ValidationFun, Path, Request,
                                        [<<"first">>, <<"second">>], WaitTime),
               Expected = {Status, Reason},
               ?WHENFAIL(io:format("FirstResponse: ~p~nExpected:"
                                   " ~p~nSecondResponse ~p~n",
                                   [FirstResponse, Expected, SecondResponse]),
                         (FirstResponse == Expected)
                         and (SecondResponse == {<<"200">>, <<"OK">>})
                        )
           end
          )
       ).
  
  %%==============================================================================
  %% Internal functions
  %%==============================================================================
  
negative.code:     ok = fusco:disconnect(Client),
      webserver:stop(Module, Listener, LS),
      Responses.
  
  expiration_time(Expires, MaxAge) ->
      case Expires of
          true ->
              MaxAge*1000;
          false ->
              0
      end.
  
  check_responses(Status, Reason, [First, Second]) ->
      Expected = {Status, Reason},
      ?WHENFAIL(io:format("First: ~p~nExpected: ~p~nSecond: ~p~n",
                          [First, Expected, Second]),
                {First, Second} == {Expected, {<<"200">>, <<"OK">>}}
               );
  check_responses(Status, Reason, [First, Second, Third]) ->
      Expected = {Status, Reason},
      ?WHENFAIL(io:format("First: ~p~nSecond: ~p~nExpected: ~p~nThird ~p~n",
                          [First, Second, Expected, Third]),
                {First, Second, Third}
                == {Expected, Expected, {<<"200">>, <<"OK">>}}
               ).
  