Clean up test code and implement returning correct buffer length when creating ruby string.