How would you implement a binary search algorithm in a way that is easy to maintain and test?
Implement an iterative function that accepts a sorted list of integers and a target integer. Return the index of the target if present, or -1 otherwise. Use clear search boundaries and ensure the function handles empty inputs and targets outside the array range.
Function signature: def binary_search(nums, target):
def binary_search(nums, target):