Add custom encoder unit tests and fix initializers.