Fix cookie handling

Some clean up
+ fix cookie handling

The test with Flash cookie works now