Add tests, make API a bit nicer