Minor code cleanup
- Removed unused or redundant conditionals
- Added more tests that cover some edge cases