Welcome to LQ victor,
Please use code bbtags to wrap your code. That being said your test is failing because you're using single quotes.
sed -i 's|$test|$test1|g' FileA
is being interpreted by bash literally. If you want bash to expand those variables you'll need to encase in double quotes or exclude the variables.
sed -i "s|$test|$test1|g" FileA
sed -i 's|'"$test"'|'"$test1"'|g' FileA
In my opinion the easier solution would be to just use vim and do the replacement there, :%s/search/replace/g