fixed tie-breaking and some test issues