rewrite binary fns to remove repetition; one broken test in IO needs TLC