introduce api package, added more tests