factored chain out into its own file, added tests, fixed inconsistent signature in case of error
version bump