     |> Enum.into(%{})
   end
 
-  def log_active(user) do
-    now = DateTime.utc_now
+  def log_active(user, timestamp \\ DateTime.utc_now) do
     record = get_user_record(user)
 
     unless record[:meta] do

          Map.put(record, :entries, entries)))
  end

  def log_inactive(user) do
    now = DateTime.utc_now
    record = get_user_record(user)

    entries = case record.entries do
                [] -> []
                [{b, _} | rest] -> [{b, now} | rest]
              end

    Agent.update(__MODULE__, &Map.put(&1, user,

      case record.entries do
        # First session seen.
        [] ->
          [{timestamp, nil}]

        # Already have an open session.
        [{_, e} | _] when is_nil e ->
