Lock-based stack with tests.