Factored out the cookie data codec and provided tests