CookieUtils.js tested and partially rewritten