Refactored a bit, fixed some bugs and added a couple of tests
Added more tests for arrays