CON-1809 | Fix overlapping of anchored element

consider moving all this function logic to controller and exposing other functions from this module as public API and use them in controller. With current solution it's impossible to write unit tests for this module or reuse any portion of code elsewhere