`paste` HTML issue when pasting `block` node

I’m trying to paste paste HTML that after parsing return math_display (block) node. Parsing works fine but the problem is with pasting. I tried to debug and I found that in replace method, tr.replaceRange is called and inside of it below

    if (fitsTrivially($from, $to, slice))
        return tr.step(new ReplaceStep(from, to, slice));

returns false and instead of replacing empty paragraph with my math_node, the content of math node (text) is inserted into paragraph. image

Above both openStart and openEnd are 1.

Any suggestions why it does not work?

Any suggstions? What openStart and openEnd are? My desired behaviour would be: that if the cursr is in empty paragraph, doPaste should replce that empty apragraph with the pasted content which is not the case.