When you run a script in ArcMap (Python window or tool) and you have a workspace set but a different layer with the same name exists in the TOC, which will be used?
I did a test with get_count, it takes the one in the TOC and ignore the workspace. When I delete the layer from the TOC I got the correct layer from the workspace.
Is this a bug??