Fix up new encoding subroutine to work within test suite