#44 refactoring tls.hs: separate StateT monad