Some refactoring, simple tests of session