fix using uninitialized value
add lock tests