Contributions for Membership completed, but Membership remains as Pending
I encountered the same issue on my CiviCRM installation. This is related to contributions status name which changed after being translated (in French at least), which prevented CiviCRM from finding the right membership status (the Completed status was translated to Complété which wasn’t correctly tested in this code).

A bug was reported to the developers by Sunil Pawar (CRM-20881), and a patch that solves this issue was submitted on GitHub.

This patch wasn’t included in the core repository yet, but in my case, the patch works fine.

Olivier;