Added unit tests and simplified camera flash logic (with tests)

Fixes [this flash related bug](https://bugzilla.mozilla.org/show_bug.cgi?id=946514)