fixing onClose firing behavior and static test to account for async behavior