Binary document decoding is now fixed

Also completed 2 tests for decoding legacy and common binary documents

I tried to understand what you wanted with common and legacy binary document. I hope it's ok