add test case for extract(weekday from timestamp), and clean code according to Paul's review