Fix bugs and add code for localytics session test