I do not understand why the javascript RegExp.test() method do no return the same result every time I call it.
RegExp.test()
Given the following javascript variables<
That's because you use the g flag. It turns the regexp object into an iterator, whose state changes with each call.
g
You don't need the g flag here, so just remove it :
var regexo = new RegExp('^'+opener+'$');