Added tests and documentation for critical sections