Make testable and add tests.

Hey,

Thanks again for your feedback on my last [pull request #24](https://github.com/ded/bowser/pull/24).
I've now split my PR into two parts and kept your coding style.
This is the first part and it's manly adding tests for the existing functionality.

The internal changes where required to make everything testable (We have to re-execute `detect()` with different user agent strings multiple times.) and make the tests succeed.