This might be a problem with connection re-use or it could be the shell behavior. The getLastError (GLE) call just returns the status of the last operation to happen on the connection that executes the GLE call.
However, when you are using the shell, it automatically calls GLE after every write operation, so you will usually get a null result because GLE has already been called. Try calling getPrevError()
instead - see if that returns what you expected.
The MongoDB drivers take care of this by making sure that GLE is called before a connection is returned to the pool and that is returned as the result (or error) for an operation to avoid this kind of problem.