Bug fixes for hanging tests