completed csr_ctx module and add unittest for it