smalloc: add tests, move out of js

Added multiple tests to cover all apparent cases.

Added checks so Alloc can be used directly from user-land.

Changed syntax so Alloc will return object, and create a new one if non
was passed.