Forward porting of #1128 by @kezabelle. Still some tests failing.
Change allowed query numbers in AdminFormsTests and GlobalPermissionTests
Yet another query number adjustment