Unittests for timestr

This pull request introduces unit tests for the timestr() function, and also fixes some bugs I found when implementing those unit tests, notably, removing from total, what has already been included in a more significant time unit (i.e. removing 60 minutes from total for every full hour).