added tests, fixed issues with array handling