Refactored to group tests more logically. No functional changes.