Fix bug in handling of pystachio bindings.

Also, add new unit test to prevent regressions.

Bugs closed: aurora-659

Reviewed at https://reviews.apache.org/r/24953/