Functional tests for issue #20

I change the functional test cases after implementing issue #20 and fix
lot of bugs from the last commit.

The functional tests for sales orders and services will be committed
later.