added cookie handling
extended functionality, fixed tests