update when and setup test to work with promises