add test for patch
add static logic
add concurrency protect and tests