Here's what you're script is outputting:
Set-Cookie: test=testvalue; path=/; expires=Sun, 24-Mar-2002 20:54:30 GMT
Date: Sun, 24 Mar 2002 19:54:30 GMT
Content-Type: text/html; charset=ISO-8859-1
Content-type: text/html
<h1>COOKIE SET</h1>
What you're getting is two "Content-type"...