Add test for duplicate definition of promise handles

Promise handles should allow the use of variables without triggering
duplicate handle errors
Merge remote-tracking branch 'nick/redmine/4682'
Fix static handle duplicate checking

Do not count handles with variable references. Do not count duplicate handles
attached to promises with different class expressions.

Close #4682