Refactoring code to convert tl_track_at_previous() in a function, also recoded
tests.