Fix completion for magics and add more tests.