add acceptance tests, fix bugs