Modified session behavior and also fixed some tests