passing tests, cover almost all edge cases