Find state field (input or select) in complete form context.

Previously, when someone was using custom checkout templates with additional wrapping elements the jQuery selector would not be able to replace the `state` field with the AJAX response.

This change searches the complete form for the `input` or `select` element with `.card_state`.

Also added a small check to see if headers are already sent before starting the session.