More minor tweaks; added type annotations to all functions to use 'T as the element type instead of 'a.
Added a few simple tests.