patch 8.0.0019
Problem:    Test_command_count is old style.
Solution:   Turn it into a new style test. (Naruhiko Nishino)
            Use more assert functions.
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 5402fc6..6ebfee4 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -1,5 +1,13 @@
 " Tests for autocommands
 
+function! s:cleanup_buffers() abort
+  for bnr in range(1, bufnr('$'))
+    if bufloaded(bnr) && bufnr('%') != bnr
+      execute 'bd! ' . bnr
+    endif
+  endfor
+endfunction
+
 func Test_vim_did_enter()
   call assert_false(v:vim_did_enter)
 
@@ -254,6 +262,9 @@
 " Tests for autocommands on :close command.
 " This used to be in test13.
 func Test_three_windows()
+  " Clean up buffers, because in some cases this function fails.
+  call s:cleanup_buffers()
+
   " Write three files and open them, each in a window.
   " Then go to next window, with autocommand that deletes the previous one.
   " Do this twice, writing the file.