Fix crash with redirects caused by a too early closed promise. Add new test for redirects.

Fixes #16