add shared lock and add more tests