Fix few bugs, update tests to work with sessions