Add tests for deque and bugfix