Check for WP_Error when querying for attachment accessibility.

See 6322b1

Props @dcavins
Use plugin_dir_path() to build includes path
Some unit test fixes