Add testing infrastructure

#29 should be merged first

This is a new version of #30