implement deque instead of queue, free refs from lua reg when in finalizers, some refactoring
remove code duplication
free ref arrays to prevent mem leak
remove test2, use same tests for test.lua(as with test_dynload)