minor refactorings and cleanup+format
added tests for EncodingManager
no null encodingManager allowed
added some more tests + fixed integration test