fix broken tests, more comprehensively test edge cases
removing dead code