Make MS.getBoundTerms() correct for batched statements

patch by Aleksey Yeschenko and Sam Tunnicliffe; reviewed by
Sylvain Lebresne