Fix failing test cases
Changes according to comments
Rename variables to avoid confusion
Merge pull request #3296 from Randy-Ma/master

Pick commits from the Revit2015 branch to the master branch