fix timer and add unitests