Refactoring, and added tests for the CsrAttributeEncoder