Adding encoder and its tests.