Adds CB-5416 to Firefox OS and clean up CB-5816

Changes to CB-5416 have been pulled and are part of 3.5 tag, but bug wasn't resolved. Resolved the bug and updating here.

Cleaned up changes in CB-5816, intermediate commit messages were not relevant.