Fix errors when generating random binary strings

There are three places in the code where iolist_to_binary() is called on a list that is not an iolist, causing the code to fail.  This patch fixes the issue.