Fix tab-completion for magics, other completion cleanup and fixes....
Fix tab-completion for magics, other completion cleanup and fixes.
Mostly simplifying the code and updating it, no major functionality changes
other than fixing magic completion, which had broken in the 0.11 refactor.
Also added a small test file for completion-specific tests.