Well, blender has no idea of knowing what is “inside” and what is “outside” since those are abstract concepts that only make sense to you the user, so it’s basically flipping a coin (which is why you’re seeing it work 50% of the time). If you want to use the mouse cursor to define what is “inside” by hovering over a face, you could just use a flood-fill selection algorithm to achieve your result. Personally, I’d start with the face under the cursor and add all connected faces to a Queue- checking each face in the queue and adding connected faces except when a selected edge is reached. When the queue is finished you should have a list of faces that need to be selected.
I usually select the outermost faces I want, hide them, select the interior faces with L and unhide. Not what you want, but another way to get the result. You could hide the edges, too, but you have to enable vertex selection first or the islands will still be connected by the edges running the other way. Then press L to select linked geometry.
But if you want to use bmesh for this, testure is right- you’ll run into an ambiguity that needs a heuristic to solve. And heuristics can be wrong! You might be able to write a better heuristic that’s wrong a lot less often, though.