Add tests and code for basic registration. Fixes #1.