Add shared var test and bug fixes.