Implement queue. Add corresponding tests.