variable replacement fixes and replaceVariables() function

moved variable replacement into replaceVariables() function.
added test for variables from included files.
fixed and added test for variable names conflicting when they are similar e.g.: @color @color2