Chmod add multiple groups
You can't. chmod +a adds one entry to the ACL, and each ACL entry refers to one user or group. From the man page:


  Each file has one ACL, containing an ordered list of entries. Each entry refers to a user or group, and grants or denies a set of permissions. 


So you'll need something like

for g in test1 test2; do
    chmod -R +a "group:$g allow ... " /path/to/directory
done