add select unitestests

add some unitests for the channel. In the process fix fix some issues in recv
from a buffered channel.

Also fix the race conditions we have while returning in the queue while the
other try to make the status entering in the queue active. We should go back to
it once we activate it or at least go back in the run queue.
rework the selech and channel algorithm

this changes prevent some race conditions raised during the tests. it make sre
we atomically change the sleeping status of a thread also that the behavior is
identical to the one in go.