Tests and bug fix for build hook.