Avoid race conditions in AlgorithmTimer
The issue (most likely) was due to the undefined behaviour of the C posix timer when calling timer_delete while a callback on timeout was already pending, but not yet executed.
Step 1: Implement a unit test reproducing the race condition.
Step 2: Change the AlgorithmTimer implementation to reproducibly pass the test.
Implemented a unit test which was failing in around 20-30% executions in the
test3() function due to this issue. Then implemented a flag protecting from the race condition and ran the test 50 times, all were successful.