Fix for #1226: Optimize "is Element" test
Tests for #1226: Optimize "is Element" test