Switch to using `Sinatra.new` to create the dynamic Sinatra app

This is the recommended way to do this in the documentation, so I
feel more comfortable moving to it. This should help future-proof
our logic and doesn't alter the functionality.
Add rack request fix to detect `HTTP_X_FORWARDED_PROTO`

This fixes the rack request port logic to consider the header
`HTTP_X_FORWARDED_PROTO`. This is in the the master branch of
rack but is not in a rolled version yet. This ensures that SSL
forwarding is handled correctly when we redirect in Sinatra
apps.
Merge pull request #25 from redding/jcr-cleanups

Minor cleanups and fixes for edge cases