BWS.write: Create promise only when necessary

promise created in the step 1 is used only when [[state]] is writable or waiting.
Move it into each case block.

Reference implementation is untouched since we're extracting handlers and making
it consistent with the spec algorithm just seems to make the code dirty.