fix cyclic dependency bug
add test
Merge pull request #1178 from optimizely/fix_infinite_lock

Fix infinite lock check