Add missing import

Also add tests

Fixes #511