Fix --profile handling
Rewrite --profile tests