Refactor tests.
Add edge case tests for empty arrays.
Fix empty array edge case.