Fixing bug when inserting sessions see BT#6449