More robust cloning function

Correctly clone Dates and RegExps, better detection of primitives and more tests.