Fix logout; add test