clean up the timestamp conversion function and add more test cases