fix and add Calendar functions, add tests