New with_context function makes code testing easier.