stats per institute: reduce loops #2575

for #2575 
Swap the conditions? If email==null, no point for checking whether it is a test account right?