I think it's quite simple.

If `rmdir TESTD` succeeds, then the two links which refer to it, `TESTD/.` and `TESTD` are removed.  So the link count of the specified directory is reduced by 2.  This can be verified on Linux by running a shell inside the directory, and running `ls -ld` after the directory has been unlinked (removed from its parent). [*]

Once a file (such as a directory) has 0 links, and no running processes with a reference (file descriptor or current directory), it will be truly deleted.

You can try to observe true deletion by looking at the used disk blocks in `df .` (or i-nodes in `df -i .`).  It works in Linux `ext4` filesystems.  Other filesystems may have more complex optimizations though, making it harder to observe.


`rmdir` fails if "pathname contains entries other than . and .." (`man 2 rmdir`).  After `rmdir` succeeds, the directory will be completely empty.  This guarantees that there are no sub-directories, so they won't have any `..` links, to keep the directory's link count above 0.

[*] Of course `ls -ld` is shorthand for `ls -ld .`.  `.` keeps working even after the directory entry is removed; in fact modern Linux does not really rely on these on-disk directory entries.  I expect the original Unix implementation would not support this test.  However I believe the reference counts still worked this way, and did not have a special-case for the removal of a directory.

If you want to trace the history here, you might be interested to research how `/bin/rmdir` [used to involve root privileges](https://groups.google.com/forum/#!topic/comp.os.minix/paKhZZWixEE).