Added BEncoder class and tests.