Added jasmine tests and fixed minor bug that showed in very rare case with typeof new Date()