Added support for optional `s_code` parameter

Implemented all the changes you suggested, and wrote a few new tests.