fix splats in calling context in certain scenarios

Also, fix nested function scopes, they alter the parent function's
scope after the nested scope finishes.

Add tests for changes.