BUG-893: improve ClassLoaderUtils safety

There is a slight possiblity for
ClassLoaderUtils.withClassLoaderAndLock() to not release the lock. Fix
this by refactoring it properly and letting users pick which flavor of
the method they want to use.

Change-Id: I07edd05323d26bfdf6800fbcd28ad9c150599a74
Signed-off-by: Robert Varga <rovarga@cisco.com>