prevent infinite recursion
add testcase
Merge pull request #478 from luvit/fixes/prevent_infinite_recursion

prevent infinite recursion