Browse security code improvements

- improved performance
- started unit tests