Fix problems in QueryForm and add full tests for forms.py