anchor.diff:          ok = couch_db:close(Db2),
           {ok, Db3} = couch_db:create(?tempdb(), [?ADMIN_CTX]),
           ok = couch_db:close(Db3),
  +
  +        wait_for_process_shutdown(DatabaseMonRef, killed,
  +          {reason, "Failure waiting for db shutdown"}),
  +        wait_for_process_shutdown(DesignDocMonRef, normal,
  +          {reason, "Failure waiting for view index shutdown"}),
   
           Writer1 = spawn_writer(Db1#db.name),
           Writer2 = spawn_writer(Db2#db.name),
  
positive.code:         ok = populate_db(MDb1, 100, 100),
          query_view(MDb1#db.name, "foo", "foo"),
          ok = couch_db:close(MDb1),
  
          {ok, Db1} = couch_db:create(?tempdb(), [?ADMIN_CTX]),
          ok = couch_db:close(Db1),
  
negative.code:         ?assertEqual(ok, stop_writer(Writer2)),
          ?assertEqual(ok, stop_writer(Writer3))
      end).
  
  wait_for_process_shutdown(Pid, ExpectedReason, Error) ->
    receive
        {'DOWN', Pid, process, _, Reason} ->
            ?assertEqual(ExpectedReason, Reason)
    after ?TIMEOUT ->
        erlang:error(
            {assertion_failed,
             [{module, ?MODULE}, {line, ?LINE}, Error]})
    end.
  
  
  create_doc(DbName, DocId) when is_list(DocId) ->
      create_doc(DbName, ?l2b(DocId));
  