Added further test cases and documentation. Renamed "flattening" to "inlining" in order to avoid using two terms.