Consolidate if statement, and update unit test