Split large methods into submethods to reduce max-complexity

By this refactoring max-complexity of PEP8 is reduced from 33 to 19.

Closes-Bug: #1399523
Change-Id: I7e9e5cefd3e72e322d8b327f495ce7fc863c3678
Merge "Split large methods into submethods to reduce max-complexity"