Tests: Fix potential NPE.
Add @Override to the inherited methods. Remove redundant casts. Remove redundant inheritance of interfaces. Remove redundant if/else clause.
bug 460335: Optimize the synchronized code.