Make sure session exists when closing it in tests