Add spec tests and some cleanup.