removed unnecessary allocations, added more tests