dagolden's collected fixes for sessions

This pull request fixes almost all of the outstanding issues with sessions that I found.

I may have a few more tests drifting in later, but I think this should be merged so others can use it for further refinements and so additional D2-ready session factories can be written against it.