Added validation and tests for valid port ranges