Session to json

Adds `toJSON` to session and some tests.