Some minor fixes and merged test cases.

This probably is the last commit made on this branch.