Various affile fixes

These patches add a few tests for various affile things, corrects the flags used at reopen time (O_APPEND was missing), and renames a function to have a single underscore instead of two.