added XMLHttpRequest magic and a test