bapil: add load and unload callbacks and allow script to return api

I suggest two enhancements for bapil: load/unload callbacks and using script's return value as api.
Callbacks can be usefull to apply/revert monkey patch on load/unload api.
Using script's return value instead of environment provides more flexibility and control for api. For example, table with metatable can be used as api.