use HTTP_REFERER as fallback if HTTP_ORIGIN is not sent

Also refactor those function a bit and move doctests into a separate
module.
fix server time offset calculation for IE10
remove doctest-ignore-unicode dependency
adjust coverage generation a bit
mv specs/ to tests/
run testsuite via setuptools