fix from_str, to_str, and their tests