Even closer to your request
:global x {test1=76;test2=276;test3=387}
/system script> :environment print
x={test1=76; test2=276; test3=387}
script test
:local i 2;
:global x
:put ($x->"test$i")
run test
276
Another example using part of the inner variable with an index
:for a from=1 to=[:len $x] do={:put ($x->"test$a")}
76
276
387