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