TRQ-2845: Fixed tmp_time math in mom_main main loop

Fixed tmp_time math
Moved the logic to a testable function
Wrote a unit test

NOTE: please take care about mom_main.c:5868: if TRQ-2761 would be merged the line have to use the calculate_select_timeout() function in place of ServerStatUpdateInterval in this line:
-  tmpTime = MIN(wait_time, (LastServerUpdateTime + ServerStatUpdateInterval) - time_now);
+  tmpTime = MIN(wait_time, (LastServerUpdateTime + calculate_select_timeout()) - time_now);