Fix convert_to_one_hot and add a test