Add unit tests
Minor bug in definition of datetimetype() function