Fix cookie whitelisting code and add tests
0.3.4