fixed #314. fixed #354. callback that sets agents cookies is now executed before users callback in .end()