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