fix copy-database issues, implement integration tests

- resolves xtuple/xtuple-server-commercial#96
- resolves #367