The rule should be that if the defensive team gains possession any previous offside is nullified and the goal stands. If a team goes in offside and cycles the puck for 30+ seconds but never loses possession and then scores then they directly benefited from the offside play and the goal should be disallowed but if the defensive team gains possession and is unable to clear, that's on them.
It would also probably make it a lot quicker if the league reviewed it and not the refs. If a play is close to being offside they can review it while play is still going on, while the players celebrate, and while the coach looks at the iPad to decide if he's challenging it or not that way if they do challenge they can give an answer in seconds instead of having the ref go over and start the process after the game has already been delayed while the coach thought about what to do.