Refactor tests && annotate rwlock and rwsem

please make it a function