Move the debug statement to where it makes more sense

It's possible to just say "select account" without a "from", so
put the debug statement at the end of the block where the variable
"formatter" is filled with the query string.
Fix query string for select account

A wrong query string was generated by "select account": one ansify_if()
too much was listed and justify() was called with the wrong parameters.

Bug fix for #744