smw.Api.query.toString() add some sanity checks

Change-Id: Ie8a07a363fd86b9a6c620b35f0ea29994c77150b
Merge "smw.Api.query.toString() add some sanity checks"