Added test and fixes for refresh