finish code and test

Usable now.