Spec various chain functions and tests for #397
Minor optimization of result
Merge pull request #1807 from megawac/chain-imp

Spec various chain functions and avoid unnecessary .call