   end
 
   test "locals: in guards" do
-    assert expand(quote(do: fn pid when :erlang.==(pid, self) -> pid end)) ==
+    assert expand_and_clean(quote(do: fn pid when :erlang.==(pid, self) -> pid end), [:import, :context]) ==
            quote(do: fn pid when :erlang.==(pid, :erlang.self()) -> pid end)
   end
 

  ## Cond

  test "cond: expands each clause" do
    assert expand_and_clean(quote do: (cond do x = 1 -> x; _ -> x end)) ==
           quote do: (cond do x = 1 -> x; _ -> x() end)
  end

  test "cond: does not share lexical scope between clauses" do
    assert expand_and_clean(quote do: (cond do 1 -> import List; 2 -> flatten([1, 2, 3]) end)) ==
           quote do: (cond do 1 -> import :"Elixir.List", []; 2 -> flatten([1, 2, 3]) end)
  end

  test "cond: does not leaks vars on head" do
    assert expand_and_clean(quote do: (cond do x = 1 -> x; y = 2 -> y end; :erlang.+(x, y))) ==
           quote do: (cond do x = 1 -> x; y = 2 -> y end; :erlang.+(x(), y()))
  end

  test "cond: leaks vars" do
    assert expand_and_clean(quote do: (cond do 1 -> x = 1; 2 -> y = 2 end; :erlang.+(x, y))) ==
           quote do: (cond do 1 -> x = 1; 2 -> y = 2 end; :erlang.+(x, y))
  end


  ## Receive

  test "receive: expands each clause" do
    assert expand(quote do: (receive do x -> x; _ -> x end)) ==
           quote do: (receive do x -> x; _ -> x() end)
  end

  test "receive: does not share lexical scope between clauses" do
    assert expand(quote do: (receive do 1 -> import List; 2 -> flatten([1, 2, 3]) end)) ==
           quote do: (receive do 1 -> import :"Elixir.List", []; 2 -> flatten([1, 2, 3]) end)
  end

  test "receive: expands guards" do
    assert expand(quote do: (receive do x when x when __ENV__.context -> true end)) ==
           quote do: (receive do x when x when :guard -> true end)
  end

  test "receive: does not leaks clause vars" do
    assert expand(quote do: (receive do x -> x; y -> y end; :erlang.+(x, y))) ==
           quote do: (receive do x -> x; y -> y end; :erlang.+(x(), y()))
  end

  test "receive: leaks vars" do
    assert expand(quote do: (receive do x -> x = x; y -> y = y end; :erlang.+(x, y))) ==
           quote do: (receive do x -> x = x; y -> y = y end; :erlang.+(x, y))
  end

  test "receive: leaks vars on after" do
    assert expand(quote do: (receive do x -> x = x after y -> y; w = y end; :erlang.+(x, w))) ==
           quote do: (receive do x -> x = x after y() -> y(); w = y() end; :erlang.+(x, w))
  end

