fixed error in string encoding and updated test to verify.