Fixed a bug with the math to calculate the input frame.
Exported some functionality to help with testing.
Added unit tests.
Added instructions for running tests.