Fix random failures (#38)

diff --git a/openwhisk/executor_test.go b/openwhisk/executor_test.go
index db8247b..5c78bea 100644
--- a/openwhisk/executor_test.go
+++ b/openwhisk/executor_test.go
@@ -19,7 +19,6 @@
 import (
 	"fmt"
 	"io/ioutil"
-	"time"
 )
 
 func ExampleNewExecutor_failed() {
@@ -64,7 +63,7 @@
 	case <-proc.exit:
 		fmt.Println("exit")
 	}
-	time.Sleep(100 * time.Millisecond)
+	waitabit()
 	proc.Stop()
 	dump(log)
 	// Output:
@@ -83,9 +82,9 @@
 	proc.io <- `{"name":"Mike"}`
 	fmt.Println(<-proc.io)
 	proc.log <- true
-	time.Sleep(100 * time.Millisecond)
+	waitabit()
 	proc.Stop()
-	time.Sleep(100 * time.Millisecond)
+	waitabit()
 	_, ok := <-proc.io
 	fmt.Printf("io %v\n", ok)
 	dump(log)
@@ -113,9 +112,9 @@
 	}
 	proc.log <- true
 	fmt.Printf("exit %v\n", exited)
-	time.Sleep(100 * time.Millisecond)
+	waitabit()
 	proc.Stop()
-	time.Sleep(100 * time.Millisecond)
+	waitabit()
 	_, ok := <-proc.io
 	fmt.Printf("io %v\n", ok)
 	dump(log)
diff --git a/openwhisk/util_test.go b/openwhisk/util_test.go
index 190e61d..6aeeeec 100644
--- a/openwhisk/util_test.go
+++ b/openwhisk/util_test.go
@@ -55,7 +55,8 @@
 
 func stopTestServer(ts *httptest.Server, cur string, buf *os.File) {
 	runtime.Gosched()
-	time.Sleep(1 * time.Second)
+	// wait 2 seconds before declaring a test done
+	time.Sleep(2 * time.Second)
 	os.Chdir(cur)
 	ts.Close()
 	dump(buf)
@@ -162,11 +163,17 @@
 	return kind.Extension
 }
 
+func waitabit() {
+	time.Sleep(1000 * time.Millisecond)
+}
+
 func TestMain(m *testing.M) {
 	sys("_test/build.sh")
 	sys("_test/zips.sh")
-	// increase timeouts
+	// increase timeouts for init
 	DefaultTimeoutInit = 1000 * time.Millisecond
+	// timeout for drain - shoud less (or you can get stuck on stdout without getting the stderr)
+	DefaultTimeoutDrain = 100 * time.Millisecond
 	code := m.Run()
 	os.Exit(code)
 }