postgresql_escape returned an invalid string if the password end in '$':
postgres=# alter role "postgres" password $$foo$$$;
ERROR: syntax error at or near "$"
LINE 1: alter role "postgres" password $$foo$$$;
This allows non-standard users (pe-postgres) to change passwords. Also
added a function to do escaping of the password, added system tests
and rspec tests for the function.