date from string, improved implementation and tests