Within the here document, your variables are being evaluated on the source side. If you want to have your variables be evaluated on the target side, escape the $. For example,
ssh -q $REMOTE -x << EOF LINK="/path/to/my/link" readlink \$LINK TEST=\$(readlink -f "\$LINK") echo \$TESTEOF
Hope this helps