Fix race conditions in policies

 * Fixed race conditions in wait-after and timeout policies
 * Unit test

Change-Id: I64d08e7645b55fabdb97cd82849685c33603614d
Merge "Fix race conditions in policies"