refactor salt method, added tests