fixed #314. Agent now saves cookies before passing to .end() callback. test included