Support for restricted DOM formula

Adding support for restricting the DOM elements with formula that will
be evaluated. Adding tests.