Fixed memory leak in mutex and added basic unit tests.