workflows: Holding Pen previous/next robustness

* Makes the previous/next object getter more robust.

* Adds unit tests for this functionality.

Signed-off-by: Jan Aage Lavik <jan.age.lavik@cern.ch>