Added additional test coverage and improved robustness