Tests and implementation (WIP for #451)