Fix location changing
Rewrite location add function and add tests