Implement __dir__ for completion and attribute fetching
Move common functions to separate class