fix a bug on persitence
add more tests