shell: Fix shell_write_async
test/cases/0002-shell: Tests for shell_write_async

This test uncovers bugs found in prev. commit