add mux tests
fix bugs pointed out by tests