(bug 51876) handle populates sites table interwiki ids correctly

along with cleaning up the code, splitting it out of Utils...

Change-Id: Ie55e2f126ba3c585a3f6719408460a7f3e2221f1
Merge "(bug 51876) handle populates sites table interwiki ids correctly"