#368, #393, tests and documentation.