Fix bug with queuePosition used where it shouldn't have been used
Add test for locking and unlocking queue