anchor.diff:  id(<<Num, Rest/binary>>, Acc) when Num-$0 >= 0, Num-$0 =< 9 ->
       id(Rest, [Num|Acc]).
   
  -endpoint(X) -> endpoint(X,"").
  -
  -endpoint(<<$:, Rest/binary>>, Acc) -> {lists:reverse(Acc), Rest};
  +endpoint(X) -> endpoint(X, "").
  +endpoint(<<$:, Rest/binary>>, Acc) -> {binary:list_to_bin(lists:reverse(Acc)), Rest};
   endpoint(<<X, Rest/binary>>, Acc) -> endpoint(Rest, [X|Acc]).
   
  -event(X) ->
  -    [Event, JSON] = binary:split(X, ?BINFRAME),
  -    {Event, JSON}.
  -
  -p_ack(X) ->
  -    case binary:split(X, <<"+">>) of
  -        [H] -> list_to_integer(binary_to_list(H));
  -        [H|T] -> list_to_tuple([list_to_integer(binary_to_list(H))|T])
  +reason(X) ->
  +    case list_to_tuple(binary:split(X, <<"+">>)) of
  +	{E} -> E;
  +	T -> T
       end.
  -
  -reason(X) ->
  -   case list_to_tuple(binary:split(X, <<"+">>)) of
  -       {E} -> E;
  -       T -> T
  -   end.
   
   %%% Tests based off the examples on the page
   %%% ENCODING
   disconnect_test_() ->
  -    [?_assertEqual(<<"0::/test">>, iolist_to_binary(disconnect("/test"))),
  -     ?_assertEqual(<<"0">>, iolist_to_binary(disconnect("")))].
  +    [?_assertEqual(<<"0::/test">>, disconnect(<<"/test">>)),
  +     ?_assertEqual(<<"0">>, disconnect(<<>>))].
   
   connect_test_() -> []. % Only need to read, never to encode
   
  
positive.code:     ?assertEqual(heartbeat, decode_packet(heartbeat())).
  
  d_message_test_() ->
      [?_assertEqual({message, 1, "", <<"blabla">>}, decode_packet(iolist_to_binary(message(1, "", "blabla")))),
       ?_assertEqual({message, 2, "", <<"bla">>}, decode_packet(iolist_to_binary(message(2, "", "bla")))),
       ?_assertEqual({message, "", "", <<"bla">>}, decode_packet(iolist_to_binary(message("", "", "bla")))),
       ?_assertEqual({message, "4+", "b", <<"bla">>}, decode_packet(iolist_to_binary(message("4+", "b", "bla")))),
       ?_assertEqual({message, "", "/test", <<"bla">>}, decode_packet(iolist_to_binary(message("", "/test", "bla"))))].
  
  d_json_test_() ->
      [?_assertEqual({json, 1, "", [{<<"a">>,<<"b">>}]},
              decode_packet(iolist_to_binary(json(1, "", [{<<"a">>,<<"b">>}])))),
          ?_assertEqual({json, 1, "/test", [{<<"a">>,<<"b">>}]},
              decode_packet(iolist_to_binary(json(1, "/test", [{<<"a">>,<<"b">>}])))),
          ?_assertEqual({json, "1+", "/test", [{<<"a">>,<<"b">>}]},
              decode_packet(iolist_to_binary(json("1+", "/test", [{<<"a">>,<<"b">>}])))),
          ?_assertEqual({json, "", "/test", [{<<"a">>,<<"b">>}]},
              decode_packet(iolist_to_binary(json("", "/test", [{<<"a">>,<<"b">>}]))))].
  
  d_event_test_() ->
      [
          ?_assertEqual({event, 1, "/test", <<"car">>, [{<<"a">>,<<"b">>}]},
              decode_packet(iolist_to_binary(event(1,"/test","car",[{<<"a">>,<<"b">>}])))),
          ?_assertEqual({event, "", "", <<"car">>, [{<<"a">>,<<"b">>}]},
              decode_packet(iolist_to_binary(event("","",<<"car">>,[{<<"a">>,<<"b">>}])))),
          ?_assertEqual({event, "3+", "", <<"car">>, [{<<"a">>,<<"b">>}]},
              decode_packet(iolist_to_binary(event("3+","",<<"car">>,[{<<"a">>,<<"b">>}]))))
      ].
  
  d_ack_test_() ->
      [?_assertEqual({ack, 4}, decode_packet(iolist_to_binary(ack(4)))),
      ?_assertEqual({ack, 4, [<<"A">>,<<"B">>]},
                    decode_packet(iolist_to_binary(ack(4,[<<"A">>,<<"B">>]))))].
  
  d_error_test_() ->
      %% No example, liberal interpretation
      [?_assertEqual({error, "end", <<"you">>, <<"die">>},
              decode_packet(iolist_to_binary(error("end","you","die")))),
          ?_assertEqual({error, "", <<"you">>}, decode_packet(iolist_to_binary(error("","you"))))].
  
  
  %%% Guillermo has no idea whether we frame the length or the whole message.
  %%% The spec means nothing there?
  %decode_packet(Data = [_|_]) ->
  %    {Length, Msg} = len(Data, undefined),
  %    {Packet, MoreData} = lists:split(Length, Msg),
  %    [parse(Packet) | case MoreData of
  %                        [] -> [];
  %                        _ -> decode_packet(MoreData)
  %                    end].
  %
  %len([?FRAME, Num | Rest], undefined) when Num >= $0, Num =< $9 ->
  %    len(Rest, Num-$0);
  %len([?FRAME | Rest], Length) ->
  %    {Length, Rest};
  %len([Num | Rest], Length) when Num >= $0, Num =< $9 ->
  %    len(Rest, Num-$0 + Length * 10).
  
  binary_utf8_split1_test_() ->
      A = <<"Привет">>,
  
negative.code:     {Id, R1} = id(Rest),
      {EndPoint, Data} = endpoint(R1),
      {json, Id, EndPoint, jsx:json_to_term(Data)};
  decode_packet(<<"7::", Rest/binary>>) ->
      {EndPoint, R1} = endpoint(Rest),
      case reason(R1) of
  