Refactor tests, comment, and edge case support