Session middleware & accompanying tests