Better fix for the completion bug + added unit test.