Refactored Wikibase Lua library code to make everything testable.

Patch set 2: addressed issues in review by addshore.
Patch set 3: more issues in review addressed
Patch set 6: Addressed issues in Jeroen's review
Patch set 7: Addressed issues in Aude's review

Change-Id: Ifab855fa635ad096fcdb94d3cad1e0c4784a6f92
Merge "Refactored Wikibase Lua library code to make everything testable."