Fix multiple ranges and add a test