Added tests for cookieHandler and fixed bug found with the tests