support keyword substitutions in query() variants

Summary:
    - added **kwparameters next to *parameters everywhere
    - pulled out _ensure_encoded function to use again
    - removed extraneous checks for None - None cant be produced by
      *args / **kwargs type arguments
    - added tests