Better undefined check for range, add test.