title: kotlin coroutine withTimeout does not cancel when using withContext to get non-blocking code
body: <p>I am using withContext to transform a function into a suspending function which does not block the calling thread.
  For this I used <a href="https://medium.com/@elizarov/blocking-threads-suspending-coroutines-d33e11bf4761" rel="nofollow noreferrer">https://medium.com/@elizarov/blocking-threads-suspending-coroutines-d33e11bf4761</a> as reference.</p>
  
  <p>Now I would like to invoke this function with a timeout. For this I use withTimeout to call the function as such: </p>
  
  <pre><code>@Test
  internal fun timeout() {
      runBlocking {
          logger.info("launching")
          try {
              withTimeout(1000) {
                  execute()
              }
          } catch (e: TimeoutCancellationException) {
              logger.info("timed out", e)
          }
      }
  }
  
  private suspend fun execute() {
      withContext(Dispatchers.IO) {
          logger.info("sleeping")
          Thread.sleep(2000)
      }
  }
  </code></pre>
  
  <p>So what I would expect is that after 1000 millis the async launched coroutine is cancelled and the TimeoutCancellationException is thrown.<br>
  But what happens is that the full 2000 millis pass and when the coroutine is completed the exception is thrown:  </p>
  
  <blockquote>
    <p>14:46:29.231 [main @coroutine#1] INFO  b.t.c.c.CoroutineControllerTest
    - launching<br>
    14:46:29.250 [DefaultDispatcher-worker-1 @coroutine#1] INFO  b.t.c.c.CoroutineControllerTest - sleeping<br>
    14:46:31.261 [main@coroutine#1] INFO  b.t.c.c.CoroutineControllerTest - timed out
    kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for
    1000 ms   at
    kotlinx.coroutines.TimeoutKt.TimeoutCancellationException(Timeout.kt:128)
      at kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:94)   at
    kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.kt:307)
      at
    kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.kt:116)
      at kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:68)    at
    java.lang.Thread.run(Thread.java:748)</p>
  </blockquote>
  
  <p>Am I using something wrong? </p>
  
  <p>Or perhaps this is the intended behavior? In the documentation the counter also gets to 2 which means 1500 millis have passed before the coroutine is cancelled: 
  <a href="https://github.com/Kotlin/kotlinx.coroutines/blob/master/docs/cancellation-and-timeouts.md#timeout" rel="nofollow noreferrer">https://github.com/Kotlin/kotlinx.coroutines/blob/master/docs/cancellation-and-timeouts.md#timeout</a></p>