Code improvements and some unification with browser detection code in javascript
Fix browser version detection and failing tests