improved 'close unused maps' test; fixed bug in map closing mechanism