Use a free monad to simplify test writing