anchor.diff:      iq_with_type(<<"set">>, NS, Payload).
   
   iq_with_type(Type, NS, Payload) ->
  -    iq(Type, [#xmlel{
  -        name = <<"query">>,
  -        attrs = [{<<"xmlns">>, NS}],
  -        children = Payload
  -    }]).
  +    iq(Type, [#xmlel{name = <<"query">>,
  +                     attrs = [{<<"xmlns">>, NS}],
  +                     children = Payload}]).
   
   roster_get() ->
       iq_get(?NS_ROSTER, []).
  +
  +roster_add_contacts(ItemSpecs) ->
  +    iq_set(?NS_ROSTER, lists:map(fun contact_item/1, ItemSpecs)).
   
   %% FIXME: there is a legacy issue here. This function should
   %% use get_jid function to let the caller make decision
   %% whether to use bare or full jid.
  -roster_add_contacts(ItemSpecs) ->
  -    Items = lists:map(
  -        fun({User, Groups, Nick}) ->
  -            #xmlel{
  -                name = <<"item">>,
  -                attrs = [{<<"jid">>, escalus_utils:get_short_jid(User)}, %% XXX
  -                         {<<"name">>, bin(Nick)}],
  -                children = [
  -                    #xmlel{name = <<"group">>,
  -                                children = [exml:escape_cdata(bin(Group))]}
  -                    || Group <- Groups]}
  -        end,
  -        ItemSpecs),
  -    iq_set(?NS_ROSTER, Items).
  +contact_item({User, Groups, Nick}) ->
  +    #xmlel{name = <<"item">>,
  +           attrs = [%% XXX
  +                    {<<"jid">>, escalus_utils:get_short_jid(User)},
  +                    {<<"name">>, bin(Nick)}],
  +           children = [#xmlel{name = <<"group">>,
  +                              children = [exml:escape_cdata(bin(Group))]}
  +                       || Group <- Groups]}.
   
   roster_add_contact(User, Groups, Nick) ->
       roster_add_contacts([{User, Groups, Nick}]).
   
  -%% FIXME: see roster_add_contacts/1 comment
  +%% FIXME: see contact_item/1 comment
   roster_remove_contact(User) ->
  -    iq_set(?NS_ROSTER, [#xmlel{
  -        name = <<"item">>,
  -        attrs = [{<<"jid">>, escalus_utils:get_short_jid(User)}, %% XXX
  -                 {<<"subscription">>, <<"remove">>}]
  -    }]).
  +    iq_set(?NS_ROSTER,
  +           [#xmlel{name = <<"item">>,
  +                   attrs = [%% XXX
  +                            {<<"jid">>, escalus_utils:get_short_jid(User)},
  +                            {<<"subscription">>, <<"remove">>}]}]).
   
   private_set(Element) ->
       iq_set(?NS_PRIVATE, [Element]).
   
   private_get(NS, Name) ->
       Element = #xmlel{name = bin(Name),
  -                          attrs = [{<<"xmlns">>, bin(NS)}]},
  +                     attrs = [{<<"xmlns">>, bin(NS)}]},
       iq_get(?NS_PRIVATE, [Element]).
   
   last_activity(User) ->
  
positive.code: search_fields([null|Rest]) ->
      [#xmlel{name = <<"field">>} | search_fields(Rest)];
  search_fields([{Key, Val}|Rest]) ->
      [#xmlel{
              name = <<"field">>,
              attrs = [{<<"var">>, Key}],
              children = [
                  #xmlel{
                      name = <<"value">>,
                      children = [
                          {xmlcdata, Val}]}]}
       | search_fields(Rest) ].
  
  search_fields_iq(JID) ->
      iq(JID, <<"get">>, [
  
negative.code:          compress/1]).
  
  -export([iq/2, iq/3]).
  
  -export([bind/1,
           session/0]).
  
  -export([setattr/3,
           to/2,
           from/2,
           tags/1]).
  
  -export([get_registration_fields/0,
           register_account/1]).
  
  -export([remove_account/0]).
  
  -import(escalus_compat, [bin/1]).
  