Fix repeated button index ordering

Discovered this issue in a test suite of a real project.

There's a submit button repeated twice: once at the top of the form, once at the bottom.  It shares the same `value` (i.e. button label) with the third button that exists in the middle of the form.

The old testbrowser assigned indexes to the three buttons in order of HTML appearance.  The current testbrowser groups them by name first, which breaks my tests.

I'm not very happy with the solution, can you suggest refactorings?

I haven't explored what happens if you have the same `name` shared between checkboxes and other controls.  It should probably be resolved before merging this.