improved session handling, new tests added