fix edge case in enqueue. improve tests.