Fix incorrect behavior with non-capitalized namespace

The code was unconditionally capitalizing the first letter.
Now using Title::capitalize() instead.

This code can be simplified further, as there is no proof
that the optimizations here significantly improve performance.

Change-Id: I2e8545ceb40385d9d4e9b709c46c8b7348d5773a
Merge "Fix incorrect behavior with non-capitalized namespace"