Fixes for expanded definition of binary
Better testing and doctesting