Fix bugs and add unit test for TFile/HFile FileAccess impl

To avoid NPE if the cursor is already at the end