Bug 987487 - [Gaia] [Build] Refactoring webapp-optimize.js and unit test...

https://bugzilla.mozilla.org/show_bug.cgi?id=987487