Added one more edge case and re-fixed test case. Cleaned up dead code