Added unit test for AccessControl and several bug fixes revealed in test results.