Remove code duplication in create_app.
Merge pull request #1397 from namusyaka/remove-code-duplication-in-create-app

Remove code duplication in create_app.