Reverts #16 and provides simpler cookie capture logic, backed by actual unit tests this time. Fixes #104 and #43