fix the way the availability is checked so that persist does not unnecessarily fail
remove some redundant functions
fix test function