rewrite OnSubscribeRefCount to handle synchronous source

Resubmitting this one having stuffed up the rebase.

Rewrite of ```OnSubscribeRefCount``` because original didn't handle synchronous source (#1688) and as far as I could see the original was fundamentally broken by this use case. Please note also includes a fix in ```OperatorMulticast``` where a null check was required. I've done the rewrite using locks rather than submit a lock-free version just to ensure that the approach is valid with the experts first.
thanks @zsxwing for all these improvements. This one I don't understand because if I move the ```lock.writeLock().lock()``` inside the if statement then that exposes a race condition where just after the ```incrementAndGet``` but before the lock, unsubscribe occurs without baseSubscription being set thus preventing unsubscription once the connect happens.