fix nasty race in differ

also make the tests not leak differs

Signed-off-by: Simon Leung <leungs@us.ibm.com>