Tweaked number_valid? to fix Semaphore tests.