Bug fix in VM._get_layers, new tests for this