Add encoder tests, refactor + fix code under test

* extract property ids into factory
* use ProperyId instead of string for dependency injection
* minor logic fixes
WikibaseTestCase pulls in all of MediaWiki....